package seg2500.messagerie.texte;

import java.util.*;
import com.lloseng.auth.*;
import com.lloseng.ocsf.server.*;
import seg2500.messagerie.*;
import java.io.*;

public class TexteManager implements Observer
{
  private ObservableOriginatorServer sender;

	public TexteManager(ObservableOriginatorServer sender) throws IOException
  {
    this.sender= sender;
  }

  /**
   * Traite les messages.
   *
   * @param obs l'objet observe.
   * @param message le message.
   */
  public void update(Observable obs, Object message) {

    OriginatorMessage m= (OriginatorMessage)message;

    if (m.getMessage() instanceof MessageTextuel) {

		System.out.println("Message (texte): " + m.getMessage().toString());
		sender.sendToAllClients((MessageTextuel)m.getMessage());
    }
  }
}
